package com.wuyou.designPatterns.facade;

import com.wuyou.designPatterns.factory.abstractfactory.factory.Page;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/**
 * PageMaker
 *
 * @Date 2024/10/14 14:48
 * @Author 无忧
 */
public class PageMaker {

    private PageMaker() {
    }

    public static void makeWelcomePage(String mailaddr, String filename) {

        try {
            Properties mailProp = Database.getProperties("maildata");
            String username = mailProp.getProperty(mailaddr);
            HtmlWriter writer = new HtmlWriter(new FileWriter(filename));
            writer.title("Welcome to " + username + " 的主页。");
            writer.paragraph(" 等着你的邮件哦！");
            writer.mailto(mailaddr, username);
            writer.close();
            System.out.println(filename + " is created for" + mailaddr + " (" + username + ")");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
